'use strict';

const Service = require('egg').Service;

class FileService extends Service {
  async find(id) {
    const file = await this.app.mysql.select('files', {
      where: { id: id },
      columns: ['id', 'name', 'filename', 'path']
    });
    return file[0];
  }

  async create(file) {
    const result = await this.app.mysql.insert('files', file);
    return result.insertId;
  }
}

module.exports = FileService;
